package com.example.pt.repository;

import com.example.pt.entity.User;

import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.sql.Date;
import java.util.List;

@Repository
public interface UserRepositories extends JpaRepository<User, Integer> {
    User findByUid(int uid);

    @Modifying // 声明为更新操作
    @Query("UPDATE User u SET u.status = :status WHERE u.uid = :uid")
    int updateStatusByUid(@Param("uid") Integer uid, @Param("status") Integer status);

    List<User> findByLastTimeBefore(Date date);
    List<User> findByRegisterDateBefore(Date date);

    //查询status不为2的所有user 即不处于违规等候的用户  用于分享率检测
    List<User> findByStatusNot(int status);

    List<User> findByStatusAndBufferDayBefore(int status, Date date);

}
